package com.aqie.security.demo.web.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Function: 切面 可以获取参数
 * @Author: aqie
 * @Date: 2019/4/3 16:29
 */
/*@Aspect
@Component*/
public class TimeAspect {
    // 任何的返回值  控制器内任何方法
    @Around("execution(* com.aqie.security.demo.web.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable {

        Object[] args = pjp.getArgs();
        for (Object arg : args) {
            System.out.println("arg is " + arg);
        }

        long start = new Date().getTime();

        Object object = pjp.proceed();

        System.out.println("time aspect 耗时:" + (new Date().getTime() - start));

        return object;
    }
}
